const axios = require('axios');
const MockAdapter = require('axios-mock-adapter');
const normalAxios = axios.create();
const mockAxios = axios.create();
import _config from "./config";
import reqTools from "../utils/reqTools";

// mock 数据
var mock = new MockAdapter(mockAxios);

mock.onGet('/hardRegister/getAll').reply((config) => {
  return new Promise(function(resolve, reject) {
    reqTools.get('/api/hardRegister',config.params).then(res => {
      resolve([200, res.data]);
    }).catch((err) => {
      resolve([500, err ]);
    });
  });
});

mock.onDelete('/hardRegister/delete').reply((config) => {
  return new Promise(function(resolve, reject) {
    reqTools.delete('/api/hardRegister/'+config.id).then((res) => {
      resolve([200, res]);
    }).catch((err) => {
      resolve([500, err ]);
    });
  });
});

export default mockAxios;
